package enterprise.manage.entity;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: zhenmingyue
 * Date: 2012-11-20
 * Time: 11:21:32
 * desc:用户银行卡管理
 */
@Entity
@Table(schema = "mg", name = "user_bankcard_info")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class UserBankCard {

    /**
     * 主键
     */
    private Long id;
    /**
     * 银行名
     */
    private String bankName;
    /**
     * 持卡人姓名
     */
    private String holder;
    /**
     * 银行卡号
     */
    private String bankNo;
    /**
     * 银行卡类型
     */
    private String bankType;
    /**
     * 截止日期
     */
    private Calendar bankDeadline;
    /**
     * 用途
     */
    private String applyTo;
    /**
     * 删除标记
     */
    private Integer delFlag;
    /**
     * 创建时间
     */
    private Calendar createTime;
    /**
     * 备注
     */
    private String remark;
    /**
     * 用户id
     */
    private User user;
     @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getHolder() {
        return holder;
    }

    public void setHolder(String holder) {
        this.holder = holder;
    }

    public String getBankNo() {
        return bankNo;
    }

    public void setBankNo(String bankNo) {
        this.bankNo = bankNo;
    }

    public String getBankType() {
        return bankType;
    }

    public void setBankType(String bankType) {
        this.bankType = bankType;
    }

    public String getApplyTo() {
        return applyTo;
    }

    public void setApplyTo(String applyTo) {
        this.applyTo = applyTo;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }


    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
    @JoinColumn(name = "userId")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Calendar getBankDeadline() {
        return bankDeadline;
    }

    public void setBankDeadline(Calendar bankDeadline) {
        this.bankDeadline = bankDeadline;
    }

    public Calendar getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Calendar createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserBankCard that = (UserBankCard) o;

        if (applyTo != null ? !applyTo.equals(that.applyTo) : that.applyTo != null) return false;
        if (bankDeadline != null ? !bankDeadline.equals(that.bankDeadline) : that.bankDeadline != null) return false;
        if (bankName != null ? !bankName.equals(that.bankName) : that.bankName != null) return false;
        if (bankNo != null ? !bankNo.equals(that.bankNo) : that.bankNo != null) return false;
        if (bankType != null ? !bankType.equals(that.bankType) : that.bankType != null) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (delFlag != null ? !delFlag.equals(that.delFlag) : that.delFlag != null) return false;
        if (holder != null ? !holder.equals(that.holder) : that.holder != null) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (remark != null ? !remark.equals(that.remark) : that.remark != null) return false;
        if (user != null ? !user.equals(that.user) : that.user != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (bankName != null ? bankName.hashCode() : 0);
        result = 31 * result + (holder != null ? holder.hashCode() : 0);
        result = 31 * result + (bankNo != null ? bankNo.hashCode() : 0);
        result = 31 * result + (bankType != null ? bankType.hashCode() : 0);
        result = 31 * result + (bankDeadline != null ? bankDeadline.hashCode() : 0);
        result = 31 * result + (applyTo != null ? applyTo.hashCode() : 0);
        result = 31 * result + (delFlag != null ? delFlag.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (remark != null ? remark.hashCode() : 0);
        result = 31 * result + (user != null ? user.hashCode() : 0);
        return result;
    }
}
